package com.a1anwang.okble.common;

import java.util.concurrent.ConcurrentLinkedQueue;

/**
 * Created by a1anwang.com on 2018/5/16.
 */

public class BLEOperationQueue<T> {
    private ConcurrentLinkedQueue<T> bleOperations = new ConcurrentLinkedQueue<>();
    /**
     * 添加
     *
     * @param operation 泛型
     */
    synchronized public void add(T operation) {

        bleOperations.add(operation);
    }
    /**
     * 移除第一个
     *
     * @return T
     */
    synchronized public T removeFirst() {
        return bleOperations.poll();
    }
    /**
     * 清理
     */
    public void clear() {
        bleOperations.clear();
    }

    public int getOperationSize() {
        return bleOperations.size();
    }

    public T getFirst() {
        return bleOperations.peek();
    }

    public boolean isEmpty() {
        return bleOperations.isEmpty();
    }
}
